function html_encode(s){
    if(typeof s == "string"){
        s = s.replace(new RegExp("\r\n", "gm"), "<br>");
        s = s.replace(new RegExp('\n', "gm"), '<br>');
        s = s.replace(new RegExp('\r', "gm"), '<br>');
        s = s.replace(new RegExp("\t", "gm"), "&nbsp;&nbsp;&nbsp;&nbsp;");
        s = s.replace(new RegExp(" ", "gm"), "&nbsp;");
        s = s.replace(new RegExp("\"", "gm"), "\\"+"\"");
    }
    return s;
};

function html_decode(s) {
    if(typeof s == "string"){
        s = s.replace(new RegExp('<br>', "gm"), '\n');
        s = s.replace(new RegExp("<br>&nbsp;&nbsp;", "gm"), "\r\n");
        s = s.replace(new RegExp("&nbsp;&nbsp;&nbsp;&nbsp;", "gm"), "\t");
        s = s.replace(new RegExp("&nbsp;", "gm"), " ");
        s = s.replace(new RegExp("\\"+"\"", "gm"), "\"");
    }
    return s;
};